package two.chapter_1.c1_3;

import edu.princeton.cs.algs4.StdOut;


public class Ex1_3_39 {

    public static void main(String[] args) {
        final RingBuffer<String> ringBuffer = new RingBuffer<>(10);
        for (int i=0;i<11;i++){
            ringBuffer.enqueue("a_" + i);
            StdOut.println("size:"+ringBuffer.size());
        }
        for (int i=0;i<10;i++){
            StdOut.println(ringBuffer.dequeue());
        }
       /* new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 200; i++) {
                    ringBuffer.enqueue("a_" + i);
                    StdOut.println("size:"+ringBuffer.size());
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }).start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 300; i++)
                   StdOut.println(ringBuffer.dequeue());
                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).

                start();*/
    }


}
